package com.hmall.trade.listener;


import com.hmall.trade.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.hmall.common.constats.MqConstants.*;
@Slf4j
@Component
public class PayStatusListener {

    @Autowired
    private IOrderService orderService;


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = PAY_SUCCESS_QUEUE)
            ,exchange = @Exchange(name = PAY_EXCHANGE,type = ExchangeTypes.TOPIC)
            ,key = PAY_SUCCESS_KEY
    ))
    public void paySuccess(Long orderId){
        log.info("支付成功消息接收成功！");
        orderService.markOrderPaySuccess(orderId);
    }
}
